import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
// 阿里巴巴字体图标
import '@/assets/iconfont/iconfont.css'
axios.interceptors.request.use(config => {
  store.commit('setError', { status: false, message: '' })
  config.headers['token'] =store.state.token
  config.headers['Content-Type'] ='application/json;charset=UTF-8'
  return config
})

axios.interceptors.response.use(config => {
  store.commit('setLoading', false)
  return config
}, e => {
  const { error } = e.response.data
  store.commit('setError', { status: true, message: error })
  store.commit('setLoading', false)
  console.log(error)
  return Promise.reject(e.response.data)
})
createApp(App).use(store).use(router).mount('#app')
